home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AMISL083.ARJ / NOLPT.ASM < prev    next >
Assembly Source File  |  1992-04-19  |  4KB  |  161 lines

  1. ;-----------------------------------------------------------------------
  2. ; NOLPT.ASM    Public Domain 1992 Ralf Brown
  3. ;        You may do with this software whatever you want, but
  4. ;        common courtesy dictates that you not remove my name
  5. ;        from it.
  6. ;
  7. ; Trap output to a particular printer port and always return 'ready'
  8. ; or success, even if no printer is attached.
  9. ;
  10. ; Version 0.80
  11. ; LastEdit: 4/19/92
  12. ;-----------------------------------------------------------------------
  13.  
  14. __TINY__ equ 1                ; using Tiny model
  15.     INCLUDE AMIS.MAC
  16.  
  17. ;-----------------------------------------------------------------------
  18. ;
  19. VERSION_NUM equ 0050h    ; v0.80
  20. VERSION_STR equ "0.80"
  21.  
  22. ;-----------------------------------------------------------------------
  23. ; Declare our segments in the order we want them in the executable.
  24. ;
  25. _TEXT    SEGMENT PUBLIC BYTE 'CODE'
  26. _TEXT    ENDS
  27. TSRcode@
  28. TSRcodeEnd@
  29.  
  30. ;-----------------------------------------------------------------------
  31. ; Put the resident code into its own segment so that all the offsets are
  32. ; proper for the new location after copying it into a UMB or down into
  33. ; the PSP.
  34. ;
  35. TSRcode@
  36. start_TSRcode label byte
  37.  
  38. ;-----------------------------------------------------------------------
  39. ; Declare the interrupt vectors hooked by the program, then set up the
  40. ; Alternate Multiplex Interrupt Spec handler
  41. ;
  42.     HOOKED_INTS 17h            ; hooking INT 17h in add. to INT 2Dh
  43.     ALTMPX    'Ralf B','NOLPT',VERSION_NUM,'Turn printer port into bit bucket',,,,,Y
  44.  
  45. ;-----------------------------------------------------------------------
  46. ; Now the meat of the resident portion, the printer interrupt handler.
  47. ; We can save one byte by specifying the hardware reset handler set up by
  48. ; the ALTMPX macro above
  49. ;
  50.     ISP_HEADER 17h,hw_reset_2Dh
  51. printer_port equ byte ptr ($+2)
  52.     cmp    dx,0            ; will be patched to printer port
  53.     jne    use_old_int17
  54.         cmp     ah,0
  55.         je      int17_func00
  56.     cmp    ah,2
  57.     je    int17_func02
  58. use_old_int17:
  59.     jmp    ORIG_INT17h
  60.  
  61. int17_func00:
  62.     ; don't output character, simply return 'ready'
  63.     ; (fall through to func02)
  64. int17_func02:
  65.     mov    ah,90h            ; yes, printer is ready
  66.     iret
  67.  
  68. resident_code_size equ offset $
  69.  
  70. TSRcodeEnd@
  71.  
  72. ;-----------------------------------------------------------------------
  73.  
  74. _TEXT SEGMENT 'CODE'
  75.     ASSUME cs:_TEXT,ds:_TEXT,es:_TEXT,ss:_TEXT
  76.     ORG 100h
  77.  
  78. NOLPT:
  79.     DISPLAY_STRING banner
  80.     CHECK_DOS_VER 2,00
  81.     mov    bx,1000h        ; set memory block to 64K
  82.     mov    ah,4Ah
  83.     int    21h
  84.     mov    si,81h
  85. cmdline_loop:
  86.     lodsb
  87.     cmp    al,' '            ; skip blanks and tabs on commandline
  88.     je    cmdline_loop
  89.     cmp    al,9
  90.     je    cmdline_loop
  91.     mov    dx,offset _TEXT:usage
  92.         cmp     al,'1'
  93.     jb    exit_with_message
  94.     cmp    al,'4'
  95.     ja    exit_with_message
  96.     mov    dx,offset _TEXT:start_TSRcode
  97.     mov    cl,4
  98.     shr    dx,cl
  99.     mov    cx,cs
  100.     add    cx,dx
  101.     mov    es,cx
  102.     ASSUME    ES:RESIDENT_CODE
  103.         mov     byte ptr ALTMPX_SIGNATURE+14,al
  104.     mov    byte ptr lpt_number,al
  105.     sub    al,'1'
  106.     mov    printer_port,al
  107.     lodsb                ; get next character
  108.     and    al,0DFh            ; force to uppercase
  109.     cmp    al,'U'
  110.     jne    installing
  111. removing:
  112.     UNINSTALL <offset _TEXT:start_TSRcode>,RELBYTE,cant_uninstall
  113.     DISPLAY_STRING removed_msg
  114.         mov     ax,4C00h
  115.     int    21h
  116.  
  117. cant_uninstall:
  118.         mov     dx,offset _TEXT:cant_remove_msg
  119.     jmp short exit_with_message
  120. already_installed:
  121.     mov    dx,offset _TEXT:already_inst_msg
  122. exit_with_message:
  123.     mov    ah,9
  124.     int    21h
  125.     mov    ax,4C01h
  126.     int    21h
  127.  
  128. installing:
  129.     ;
  130.     ; place any necessary pre-initialization here
  131.     ;
  132.     INSTALL_TSR <offset _TEXT:start_TSRcode>,RELBYTE,resident_code_size,BYTE,,BEST,,inst_notify,already_installed,cant_install
  133.  
  134. cant_install:
  135.     mov    dx,offset _TEXT:cant_install_msg
  136.     jmp    exit_with_message
  137.  
  138. inst_notify:
  139.     DISPLAY_STRING installed_msg
  140.     ret
  141.  
  142. banner    db 'NOLPT v',VERSION_STR,'  Public Domain 1992 Ralf Brown',13,10,'$'
  143. usage    db 'Usage:',9,'NOLPT 1',9,9,'disable LPT1',13,10
  144.     db 9,'...',13,10
  145.     db 9,'NOLPT 4',9,9,'disable LPT4',13,10
  146.     db 9,'NOLPT 1U',9,'uninstall from LPT1',13,10
  147.     db 9,'etc.',13,10
  148.     db '$'
  149. installed_msg     db "Installed on LPT"
  150. lpt_number     db " "
  151.          db ".",13,10,"$"
  152. cant_install_msg db "Unable to install.",13,10,"$"
  153. already_inst_msg db "Already installed.",13,10,"$"
  154. cant_remove_msg  db "Can't remove from memory.",13,10,"$"
  155. removed_msg     db "Removed.",13,10,"$"
  156. _TEXT ENDS
  157.  
  158.      end NOLPT
  159.  
  160.  
  161.